import Router from 'vue-router'
Vue.use(Router)


// 解决编程式路由往同一地址跳转时会报错的情况
const originalPush = Router.prototype.push;
const originalReplace = Router.prototype.replace;

// push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch(err => err);
};

//replace
Router.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalReplace.call(this, location, onResolve, onReject);
  return originalReplace.call(this, location).catch(err => err);
};

import cainiao from './cainiao.js'

export default new Router({
	mode: 'history',
	base: '/web',
	routes: [

    {
      path: '/',
      redirect:'/index'
    },
    ...cainiao,
    //商品管理
    {
    	path: '/shangpinguanli',
      component: () => import('@/views/shangpinguanli/index'),
      redirect:'/shangpinguanli/gongyingshangshangpin',
      children:[
        {
          path: '/shangpinguanli/gongyingshangshangpin',
          component: () => import('@/views/shangpinguanli/gongyingshangshangpin'),
          mete:{
            title:"商品管理",
          },
        },
        {
          path: '/shangpinguanli/gongyingshangshangpin2',
          component: () => import('@/views/shangpinguanli/gongyingshangshangpin2'),
          mete:{
            title:"商品管理",
          },
        },
        {
          path: '/shangpinguanli/zaishoushangpin',
          component: () => import('@/views/shangpinguanli/zaishoushangpin'),
          mete:{
            title:"商品管理",
          },
        },
        {
          path: '/shangpinguanli/zaishoushangpinchakanziliao',
          component: () => import('@/views/shangpinguanli/zaishoushangpinchakanziliao'),
          mete:{
            title:"商品管理",
          },
        },
        {
          path: '/shangpinguanli/shangpinziliaoku',
          component: () => import('@/views/shangpinguanli/shangpinziliaoku'),
          mete:{
            title:"商品管理",
          },
        },
        {
          path: '/shangpinguanli/zaishoushangpin/zaishoushangpinpaixu',
          component: () => import('@/views/shangpinguanli/zaishoushangpinpaixu'),
          mete:{
            title:"商品管理排序",
          },
        },
        {
          path: '/shangpinguanli/gongyingshangshangpin/bianjishangpin',
          component: () => import('@/views/shangpinguanli/bianjishangpin'),
          mete:{
            title:"编辑商品",
          },
        }
      ]
    },
    //分销商管理
    {
    	path: '/fenxiaoshangguanli',
      component: () => import('@/views/fenxiaoshangguanli/index'),
      redirect:'/fenxiaoshangguanli/fenxiaoshangguanli',
      children:[
        {
          path: '/fenxiaoshangguanli/fenxiaoshangguanli',
          component: () => import('@/views/fenxiaoshangguanli/fenxiaoshangguanli'),
          mete:{
            title:"分销商管理",
          },
        },
        {
          path: '/fenxiaoshangguanli/zhaomufenxiaoyuan',
          component: () => import('@/views/fenxiaoshangguanli/zhaomufenxiaoyuan'),
          mete:{
            title:"招募分销员",
          },
        },
      ]
    },
    //订单管理
    {
    	path: '/dingdanguanli',
      component: () => import('@/views/dingdanguanli/index'),
      redirect:'/dingdanguanli/dingdanchuli',
      children:[
        {
          path: '/dingdanguanli/dingdanchuli',
          component: () => import('@/views/dingdanguanli/dingdanchuli'),
          mete:{
            title:"我的订单",
          },
        },
        {
          path: '/dingdanguanli/fenxiaoshangdingdan',
          component: () => import('@/views/dingdanguanli/fenxiaoshangdingdan'),
          mete:{
            title:"分销商订单",
          },
        },
        {
          path: '/dingdanguanli/dingdanchuli/mdingdanchuli',
          component: () => import('@/views/dingdanguanli/mdingdanchuli'),
          mete:{
            title:"订单详情",
          },
        },

      ]
    },
    //佣金管理
    {
    	path: '/yongjin',
      component: () => import('@/views/yongjin/index'),
      redirect:'/yongjin/yongjinshouru',
      children:[
        {
          path: '/yongjin/yongjinshouru',
          component: () => import('@/views/yongjin/yongjinshouru'),
          mete:{
            title:"佣金收入",
          },
        },
        {
          path: '/yongjin/yongjintixian',
          component: () => import('@/views/yongjin/yongjintixian'),
          mete:{
            title:"佣金提现",
          },
        },
        {
          path: '/yongjin/yongjinbaobiao',
          component: () => import('@/views/yongjin/yongjinbaobiao'),
          mete:{
            title:"佣金报表",
          },
        },
      ]
    },
    //系统配置
    {
      path: '/xitongpeizhi',
      component: () => import('@/views/xitongpeizhi/xitongpeizhi'),
      mete:{
        title:"系统配置",
      },
    },
    //个人管理
    {
      path: '/gerenpeizhi',
      component: () => import('@/views/gerenpeizhi/gerenpeizhi'),
      mete:{
        title:"个人管理",
      },
    },
    //个人信息
    {
      path: '/geren',
      component: () => import('@/views/geren/index'),
      redirect:'/geren/geren',
      children:[
        {
          path: '/geren/geren',
          component: () => import('@/views/geren/geren'),
          mete:{
            title:"个人中心",
          },
        },
        {
          path: '/geren/huanshoujihao',
          component: () => import('@/views/geren/huanshoujihao'),
          mete:{
            title:"换手机号",
          },
        },
        {
          path: '/geren/dengjiguize',
          component: () => import('@/views/geren/dengjiguize'),
          mete:{
            title:"等级规则",
          },
        },
        {
          path: '/geren/dingdanzhuangtai',
          component: () => import('@/views/geren/dingdanzhuangtai'),
          mete:{
            title:"订单状态",
          },
        },
        {
          path: '/geren/shangchuantouxiang',
          component: () => import('@/views/geren/shangchuantouxiang'),
          mete:{
            title:"上传头像",
          },
        },

      ]
    },
    //系统更新通知
    {
    	path: '/tongzhi',
      component: () => import('@/views/tongzhi/index'),
      redirect:'/tongzhi/tongzhi',
      children:[
        {
          path: '/tongzhi/tongzhi',
          component: () => import('@/views/tongzhi/tongzhi'),
          mete:{
            title:"系统通知管理",
          },
        },
        {
          path: '/tongzhi/tongzhixitong',
          component: () => import('@/views/tongzhi/tongzhixitong'),
          mete:{
            title:"系统通知管理",
          },
        },
        {
          path: '/tongzhi/mtongzhi',
          component: () => import('@/views/tongzhi/mtongzhi'),
          mete:{
            title:"系统通知管理",
          },
        },

      ]
    },
    //微小店
    // {
    //   path: '/weixiaodian',
    //   component: () => import('@/views/weixiaodian'),
    //   mete:{
    //     title:"微小店",
    //   },
    // },
    {
      path: '/weixiaodian',
      component: () => import('@/views/index/weixiaodian'),
      mete:{
        title:"微小店",
      },
    },

    //注册登录-商户
    {
        path: '/login',
        component: () => import('@/views/login'),
        mete:{
          title:"注册登录",
        }
      },
    //注册登录-管理员
    {
        path: '/login2',
        component: () => import('@/views/login2'),
        mete:{
          title:"注册登录",
        }
    },
    {
      path: '/index',
      component: () => import('@/views/index'),
      mete:{
        title:"首页",
      }
    },
    {
      path: '/coding',
      component: () => import('@/views/coding'),
      mete:{
        title:"开发中",
      }
    },
    //注册登录
    {
        path: '/mlogin/login',
        component: () => import('@/views/mlogin/login'),
        mete:{
          title:"登录首页",
        }
    },
    {
        path: '/mlogin/bangdingshoujihao',
        component: () => import('@/views/mlogin/bangdingshoujihao'),
        mete:{
          title:"微信注册绑定手机号",
        }
    },
    {
        path: '/mlogin/bangdingshoujihaologin',
        component: () => import('@/views/mlogin/bangdingshoujihaologin'),
        mete:{
          title:"微信登录绑定手机号",
        }
    },

    {
        path: '/mlogin/denglu',
        component: () => import('@/views/mlogin/denglu'),
        mete:{
          title:"登录",
        }
    },
    {
        path: '/mlogin/zhuce',
        component: () => import('@/views/mlogin/zhuce'),
        mete:{
          title:"注册",
        }
    },
    {
        path: '/mlogin/zhaohuimima',
        component: () => import('@/views/mlogin/zhaohuimima'),
        mete:{
          title:"重置密码",
        }
    },
	]
})
